# cp ~/nfs/config/pinyin/* ~/.local/share/fcitx5/pinyin
# sudo apt install fcitx-bin fcitx-googlepinyin
# 使用中州韵输入法是，F4可以切换简繁体输入
if [ -z `which fcitx5` ]; then \
	# https://zhuanlan.zhihu.com/p/508797663
    sudo apt install -y fcitx5 fcitx5-chinese-addons \
    fcitx5-rime \
    fcitx5-frontend-gtk3 fcitx5-frontend-gtk2  fcitx-config-gtk \
    fcitx5-frontend-qt5 kde-config-fcitx5 fcitx-frontend-qt5


    echo "[Desktop Entry]
Name=Fcitx 5
GenericName=Input Method
Comment=Start Input Method
Exec=/usr/bin/fcitx5
Icon=fcitx
Terminal=false
Type=Application
Categories=System;Utility;
StartupNotify=false
X-GNOME-AutoRestart=false
X-GNOME-Autostart-Notify=false
X-KDE-autostart-after=panel
X-KDE-StartupNotify=false
X-KDE-Wayland-VirtualKeyboard=true " > ~/.config/autostart/fcitx5.desktop

    # 以下内容添加到 ~/.pam_environment 文件中, 不然edge浏览器输入中文时，字母会乱跳
    echo "GTK_IM_MODULE=fcitx
    QT_IM_MODULE=fcitx
    XMODIFIERS=@im=fcitx
    INPUT_METHOD=fcitx
    SDL_IM_MODULE=fcitx
    GLFW_IM_MODULE=ibus " > ~/.pam_environment

    # 安装皮肤
    git clone git@github.com:thep0y/fcitx5-themes.git ~/tmp/fcitx5-themes
    mkdir -p ~/.local/share/fcitx5/themes/
    mkdir -p  ~/.config/fcitx5/conf
    cp -r ~/tmp/fcitx5-themes/* ~/.local/share/fcitx5/themes/

    # 配置
    echo "Vertical Candidate List=False 
PerScreenDPI=True
Font="Smartisan Compact CNS 13"
Theme=spring " > ~/.config/fcitx5/conf/classicui.conf
fi
	
mkdir -p ~/.local/share/fcitx5/pinyin/dictionaries/

wget -e "https_proxy=http://127.0.0.1:7890" -P ~/Downloads/ https://github.com/felixonmars/fcitx5-pinyin-zhwiki/releases/download/0.2.4/zhwiki-20220416.dict
mv ~/Downloads/zhwiki-20220416.dict ~/.local/share/fcitx5/pinyin/dictionaries/


wget -e "https_proxy=http://127.0.0.1:7890" -P ~/Downloads/ https://github.com/wuhgit/CustomPinyinDictionary/releases/download/assets/CustomPinyinDictionary_Fcitx_20240621.tar.gz

tar -zxvf ~/Downloads/CustomPinyinDictionary_Fcitx_20240621.tar.gz  -C ~/Downloads
mv ~/Downloads/CustomPinyinDictionary_Fcitx.dict ~/.local/share/fcitx5/pinyin/dictionaries/
